<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('后台登录')"></head>
    <link rel="stylesheet" th:href="@{/static/plugin/x-admin/css/font.css}" />
    <link rel="stylesheet" th:href="@{/static/plugin/x-admin/css/xadmin.css}"/>
</head>
<body class="login-bg">
    <div class="login">
        <div class="message">BEONE LayUI Admin</div>
        <div id="darkbannerwrap"></div>
        <form method="post" action="/loginValidator" class="layui-form">
            <input name="username" placeholder="用户名" autocomplete="off" type="text"
                   lay-verify="username" class="layui-input" value="supervisor"/>
            <hr class="hr15" />
            <input name="password" lay-verify="password" placeholder="密码" autocomplete="off"
                   type="password" class="layui-input" value="123456"/>
            <hr class="hr15" />
            <div class="layui-inline">
                <label class="layui-form-label" style="width:40px;padding: 9px 0px;">验证码:</label>
                <div class="layui-input-inline">
                    <input type="text" name="validateCode" style="width:150px;height:35px;"
                           autocomplete="off" lay-verify="code" class="layui-input"/>
                </div>
                <div class="layui-input-inline">
                    <img th:src="@{/getCode}" id="code" />
                </div>
            </div>
             <div>
                 <label class="layui-form-label" style="width:40px;padding: 9px 0px;">记住我:</label>
                 <input type="checkbox"  name="rememberMe" lay-skin="switch"
                        lay-filter="switchTest" lay-text="ON|OFF"  th:checked="${rememberMe}"/>
             </div>
            <hr class="hr15" />
            <input value="登录"   lay-submit="x"   lay-filter="login" style="width:100%;" type="submit" />
            <hr class="hr20" />
        </form>
    </div>
<script th:inline="javascript">/*<![CDATA[*/
    var layer;
    $(function () {
        var logout = [[${param.logout}]], error = [[${param.error}]], message = [[${session.SPRING_SECURITY_LAST_EXCEPTION?.message}]];
        if(logout){
            layuiUtils.toastMsg({content:'退出系统成功!',icon:'success'});
        }

        if(error && message){ //登录异常
            if("坏的凭证" == message){
                message = '密码错误!';
            }
            layuiUtils.toastMsg({content: message,icon:'fail', anim:'fail'});
        }

        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            form.verify({
                username: function (v) {
                    if (v.trim() == '') {
                        return "用户名不能为空";
                    }
                }
                , password: function (v) {
                    if (v.trim() == '') {
                        return "密码不能为空";
                    }
                }, code: function (v) {
                    if (v.trim() == '') {
                        return '验证码不能为空';
                    }
                }
            });
            form.render();
        });
        layer = layui.layer;

        $("#code").click(function () {
            var url = /*[[@{/getCode}]]*/ "/getCode";
            this.src = url + "?" + new Date().getTime();
        }).click().show();
        $('#code').on('mouseover', function () {
            layer.tips('点击刷新验证码', this, {time: 1000});
        });
    })

    if (window != top) {
        top.location.href = location.href;
    }
/*]]>*/</script>
<!-- 底部结束 -->
</body>
</html>